package com.core.dao.jdbcmysql;

import com.core.dao.ITransaction;

import java.sql.Connection;

public class TransactionJDBC extends JdbcBase implements ITransaction {

    @Override
    public void open()throws Exception {
     Connection con =   getConnection();
     con.setAutoCommit(false);
    }

    @Override
    public void close() {
        try {
            Connection con = getConnection();
            con.close();
        }catch (Exception e){
            throw new RuntimeException(e.getMessage());
        }
    }

    @Override
    public void commit() throws Exception {
        Connection con =   getConnection();
        con.commit();
    }

    @Override
    public void rollback()  {
        try {
            Connection con = getConnection();
            con.rollback();
        }catch (Exception e){
            throw  new RuntimeException(e.getMessage());
        }
    }
}
